<?php
$file=fopen($_POST["file"],"a+");
if(isset($_POST["mess"])){
   $string=$_POST["mess"];
   fputs($file,$string);
}

fclose($file);
window.close();
?>